#include "gd32f4xx.h"
#include "systick.h"
#include <stdio.h>
#include "main.h"
#include "tim.h"
#include "gpio.h"
#include "usart.h"
#include "wwdg.h"
#include "user_device.h"
#include <setjmp.h>
#include "spi.h"


extern jmp_buf main_loop_env;

int main(void)
{
    uchar i;
    systick_config();
    MX_GPIO_Init();
    MX_USART1_UART_Init();
    MX_TIM0_Init();
    MX_TIM1_Init();
    MX_TIM2_Init();
    MX_TIM3_Init();
    MX_TIM5_Init();
    MX_TIM6_Init();
    MX_TIM7_Init();
    //MX_TIM8_Init();
    MX_TIM11_Init();
    MX_TIM13_Init();
    MX_SPI2_Init();
#if USE_WATCHDG
    MX_WWDG_Init();
#endif
    Device_Init();

    setjmp(main_loop_env);
    while (1)
    {
        Main_Loop();
        // Tst_Systick_Timer6();
        // 处理动作
        if (pending_action)
        {
            pending_action = 0;
            Process_Action();
        }
        for(i = 0; i < KEY_START_COUNT; ++i)
        {
            Process_Starter(i);
            Process_Event(i);
            Key_Led_Ctrl(i);
        }
    }
}
